package dao

import (
	"affairs/model"
	"affairs/tool"
	"fmt"
)

type UserDao struct {
	*tool.Orm
}

/**
插入用户信息
 */
func (userDao *UserDao) InsertUser(user model.User) int64 {
	result, err := userDao.InsertOne(&user)
	if err != nil {
		panic(err)
		return 0
	}
	return result
}

/**
通过手机号获取用户信息
 */
func (userDao *UserDao) GetInfoByPhone(phone string) *model.User {
	var userInfo model.User
	if _,err := userDao.Where("phone = ?",phone).Get(&userInfo); err != nil {
		fmt.Println(err.Error())
	}
	//_,err := userDao.Where("phone = ?",phone).Get(&userInfo)
	fmt.Println("test")
	return &userInfo
}
